#!/usr/bin/python

# this scrip is used by testing.sh.
# recieve output file generated by simulationCell.cc and a name of
# directory in wich save state of cell.
#
# use: ./printImages.py dataToPlot dirname
# remember tha dataToplot is the output of simulationCell.cc

import sys
from pylab import *

if len(sys.argv) < 1:
    print("Upps, I need the datafile to plot")
    quit()

folder="../images/cell/"+sys.argv[2]+"/"
print("Plotting data from "+sys.argv[1]+" to "+folder)
#  Import the data from a text file and save as a 2D matrix
dataMatrix1 = genfromtxt(sys.argv[1])
names = ["V","INa","IK1","Ito","IKur","IKr","IKs","ICal","IpCa","INaK","INaca","IbNa","IbCa","[Ca]i","[Ca]up","[Ca]rel"]
x = dataMatrix1[:,0]
for i in range(1,len(names)+1):
    filename = folder+names[i-1]+".png"
    print(filename)
    plot(x,dataMatrix1[:,i],label=names[i-1])
    legend(loc='upper right')
    xlabel("t",fontsize=16)
    plt.ylabel(names[i-1],fontsize=16)
    savefig(filename);
    clf()
    cla()
